Skip to content

fix(http): unescape quoted header values before percent-decoding - #333

Open
EmiRZx wants to merge 3 commits into
cloudevents:mainfrom
EmiRZx:http-quoted-header-values
Open

EmiRZx wants to merge 3 commits into
cloudevents:mainfrom
EmiRZx:http-quoted-header-values

Conversation

@EmiRZx

@EmiRZx EmiRZx commented Nov 30, 2026 •

Copy link
Copy Markdown

Related Issue: #332

Type of change:

  • Bug fix (non-breaking change which fixes an issue)

Description:

_decode_header_value now trims surrounding whitespace and removes grouping double quotes, honouring backslash escapes, before percent-decoding, per HTTP binding 3.1.3.2. Same behaviour as sdk-go (cloudevents/sdk-go#1356). Unquoted values decode as before.

Touches the same line as #310; whichever lands second needs a trivial rebase.


Pre-submission checklist:

  • I have read the CONTRIBUTING.md file.
  • I have signed off my commits using git commit --signoff.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the documentation (README.md, CHANGELOG.md, etc.) as necessary.
  • I have run pre-commit and tox and all checks pass. (No tox config in the repo; ran uv run pytest tests.)
  • This pull request is ready to be reviewed.

HTTP binding 3.1.3.2 requires double-quoted strings in header values to
be unescaped before percent-decoding. The core decoder kept the quotes,
and a quoted ce-specversion was rejected.

Signed-off-by: emir <52245396+EmiRZx@users.noreply.github.com>
@PlugaruT

PlugaruT commented Dec 1, 2026

Copy link
Copy Markdown
Member

@EmiRZx changes LGTM, can you also add a line in changelogs file please

Signed-off-by: emir <52245396+EmiRZx@users.noreply.github.com>
@EmiRZx

EmiRZx commented Dec 1, 2026

Copy link
Copy Markdown
Author

added under Unreleased → Fixed.

Comment thread src/cloudevents/core/bindings/http.py Outdated
def _unescape_header_value(value: str) -> str:
"""
Undo HTTP quoting of a header value, as required before percent-decoding
(HTTP binding section 3.1.3.2).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep an active link to the docs section.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the link in c7fa474.

Comment thread src/cloudevents/core/bindings/http.py Outdated
:return: The header value without HTTP quoting
"""
value = value.strip(" \t")
if '"' not in value:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this basically does iter over the value again, just like you do below, only without modifying anything.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, removed the early return in c7fa474.

Signed-off-by: emir <52245396+EmiRZx@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants